package com.lantosec.hmrp.modules.form.vo;

import com.lantosec.hmrp.core.mvc.BaseVO;
import com.lantosec.hmrp.modules.form.entity.FormColumns;
import com.lantosec.hmrp.modules.form.entity.FormTable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 自定义表单表定义 VO对象
 * </p>
 *
 * @author AutoCode
 * @since 2020-04-15
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="Table对象", description="自定义表单表定义")
public class FormTableVO extends BaseVO<FormTable> {
    private static final long serialVersionUID = 1L;


    public FormTableVO(FormTable entity){
        this.tableId = entity.getTableId();
        this.tableSchema = entity.getTableSchema();
        this.tableName = entity.getTableName();
        this.tableType = entity.getTableType();
        this.tableDef = entity.getTableDef();
        this.tableComment = entity.getTableComment();
        this.parentId = entity.getParentId();
        this.createDate = entity.getCreateDate();
        this.createUserId = entity.getCreateUserId();
        this.createUserName = entity.getCreateUserName();
        //this.childList = entity.getChildList();
    }

    @Override
    public FormTable convertToEntity(){
        return new FormTable(this);
    }


    @ApiModelProperty(value = "ID")
    private String tableId;

    @ApiModelProperty(value = "表所在数据库")
    private String tableSchema;

    @ApiModelProperty(value = "表名")
    private String tableName;

    @ApiModelProperty(value = "表类型，BASE TABLE基本表，VIEW视图")
    private String tableType;

    @ApiModelProperty(value = "表定义，PRIMARY主表，DETAILED明细表")
    private String tableDef;

    @ApiModelProperty(value = "表描述")
    private String tableComment;

    @ApiModelProperty(value = "上级表ID")
    private String parentId;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "创建用户ID")
    private String createUserId;

    @ApiModelProperty(value = "创建用户名称")
    private String createUserName;

    @ApiModelProperty(value = "详情表集合")
    private List<FormTable> childList;

    @ApiModelProperty(value = "列集合")
    private List<FormColumns> columns;
}
